﻿using System;

namespace Nomad.ASPMVVM {
    public class BindingCommand : ICommand {
        private readonly Action executeAction;

        public BindingCommand(Action executeAction) {
            this.executeAction = executeAction;
        }

        public void Execute(object parameter) {
            if (this.executeAction != null) {
                executeAction.Invoke();
            }
        }
    }

    public class BindingCommand<TParameter> : ICommand {
        private readonly Action<TParameter> executeAction;

        public BindingCommand(Action<TParameter> executeAction) {
            this.executeAction = executeAction;
        }

        public void Execute(object parameter) {
            if (this.executeAction != null) {
                executeAction.Invoke((TParameter)parameter);
            }
        }
    }
}
